package com.qfedu.openplateform.manager.service.impl;

import com.qfedu.openplateform.manager.dao.TokenMapper;
import com.qfedu.openplateform.manager.entity.UserToken;
import com.qfedu.openplateform.manager.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TokenServiceImpl implements TokenService {

    @Autowired
    private TokenMapper tokenMapper;

    @Override
    public List<UserToken> findAllUserToken(Integer page, Integer limit) {
        return tokenMapper.findAllUserToken();
    }


    @Override
    public int updateUserTokenById(UserToken userToken) {
        return tokenMapper.updateUserTokenById(userToken);
    }

    @Override
    public int deleteUserTokenById(Integer[] ids) {

        for (Integer id : ids) {
            tokenMapper.deleteUserTokenById(id);
        }

        return 0;
    }

    @Override
    public List<UserToken> findAllUserTokenByAccessToken(String accessToken, Integer page, Integer limit) {
        return tokenMapper.findAllUserTokenByAccessToken(accessToken);
    }
}
